const fs = require('fs-extra')
const path = require('path')
const vscode = require('vscode')

const chooseTEMPDIR = (type) => {
  return path.resolve(__dirname, `./${type}`)
}
// const TEMPDIR = path.resolve(__dirname, './templates')

module.exports = (type, targetPath) => {
  return new Promise((resolve, reject) => {
    if (!fs.statSync(targetPath).isDirectory()) {
      vscode.window.showErrorMessage("当前非文件夹")
      reject("not a dir!")
      return;
    }
    fs.copy(chooseTEMPDIR(type), targetPath, err => {
      if (err) {
        reject(err)
      } else {
        resolve()
      }
    })
  })
}
